/**
 * 2024/01/01 - 2024/12/31
 **/
package com.snail.camunda.engin.identity.controller;

import com.snail.camunda.engin.identity.dto.UserInsertDTO;
import com.snail.camunda.engin.identity.dto.UserModifyDTO;
import com.snail.camunda.engin.identity.dto.UserQueryDTO;
import com.snail.camunda.engin.identity.manager.UserManager;
import com.snail.camunda.engin.identity.vo.UserVO;
import com.snail.starter.commons.page.PageQO;
import com.snail.starter.commons.page.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author: (zg)
 * @Date: 2024/12/16 13:12
 * @Version: 1.0.0
 */
@Api(tags = {"用户管理(工作流)"})
@RestController
@RequestMapping("/tenant/{tenantId}/group/user")
public class UserController {

    @Resource
    UserManager identityManager;

    @PostMapping
    @ApiOperation(value = "新增用户")
    public String add(@PathVariable("tenantId") String tenantId, @PathVariable("groupId") String groupId, @RequestBody UserInsertDTO dto){
        return identityManager.add(tenantId, groupId, dto);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改用户")
    public boolean modify(@PathVariable("id") String id, @RequestBody UserModifyDTO dto){
        return identityManager.modify(id, dto);
    }

    @GetMapping("/{id}")
    @ApiOperation("修改用户")
    public UserVO queryById(@PathVariable("id") String id){
        return identityManager.queryById(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除用户")
    public boolean delete(@PathVariable("id") String id){
        return identityManager.deleteById(id);
    }

    @PostMapping("/users")
    @ApiOperation("用户列表")
    public List<UserVO> list(@RequestBody UserQueryDTO dto){
        return identityManager.list(dto);
    }

    @PostMapping("/pages")
    @ApiOperation("用户列表(分页)")
    public PageVO<UserVO> pages(@RequestBody PageQO<UserQueryDTO> page){
        return identityManager.page(page);
    }

}